9d9868f6d3f4e49b33401ec37d371dfad1bf874f
8 * implements Special:Unusedimages
11 class UnusedimagesPage
extends ImageQueryPage
{
13 function isExpensive() { return true; }
16 return 'Unusedimages';
19 function sortDescending() {
22 function isSyndicated() { return false; }
25 global $wgCountCategorizedImagesAsUsed, $wgDBtype;
26 $dbr = wfGetDB( DB_SLAVE
);
30 $epoch = 'UNIX_TIMESTAMP(img_timestamp)';
33 $epoch = '((trunc(img_timestamp) - to_date(\'19700101\',\'YYYYMMDD\')) * 86400)';
36 $epoch = 'img_timestamp';
39 $epoch = 'EXTRACT(epoch FROM img_timestamp)';
42 if ( $wgCountCategorizedImagesAsUsed ) {
43 list( $page, $image, $imagelinks, $categorylinks ) = $dbr->tableNamesN( 'page', 'image', 'imagelinks', 'categorylinks' );
45 return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value,
46 img_user, img_user_text, img_description
47 FROM ((($page AS I LEFT JOIN $categorylinks AS L ON I.page_id = L.cl_from)
48 LEFT JOIN $imagelinks AS P ON I.page_title = P.il_to)
49 INNER JOIN $image AS G ON I.page_title = G.img_name)
50 WHERE I.page_namespace = ".NS_FILE
." AND L.cl_from IS NULL AND P.il_to IS NULL";
52 list( $image, $imagelinks ) = $dbr->tableNamesN( 'image','imagelinks' );
54 return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value,
55 img_user, img_user_text, img_description
56 FROM $image LEFT JOIN $imagelinks ON img_name=il_to WHERE il_to IS NULL ";
60 function getPageHeader() {
61 return wfMsgExt( 'unusedimagestext', array( 'parse' ) );
69 function wfSpecialUnusedimages() {
70 list( $limit, $offset ) = wfCheckLimits();
71 $uip = new UnusedimagesPage();
73 return $uip->doQuery( $offset, $limit );